package com.example.youyouhaodian.config;

import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Order(Ordered.HIGHEST_PRECEDENCE) //排序  相当于一个过滤器  HIGHEST_PRECEDENCE最高，最优先执行
@Configuration//是一个配置类
@EnableTransactionManagement(proxyTargetClass = true)  //启动jpa的数据管理
//EnableJpaRepositories启用了jpa资源库并指定了定义的接口资源库的位置
//EntityScan指定了实体类的位置

@EnableJpaRepositories(basePackages = "com.example.demo.dao")
@EntityScan(basePackages = "com.example.demo.entity")
public class Jpaconfig {
    @Bean
    PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor(){
        return new PersistenceExceptionTranslationPostProcessor();
    }

}
